package cn.com.bluemoon.daps.sync.core.sync;

import cn.com.bluemoon.daps.sync.service.ModifySyncStatusHandler;
import cn.com.bluemoon.daps.sync.vo.applypublish.ModelCompareVo;

import java.util.List;

/**
 * @author Jarod.Kong
 */
public class ModifySyncStatusContext {
    private final List<ModifySyncStatusHandler> handlers;
    private final ModelCompareVo modelTableCompareVo;

    public ModifySyncStatusContext(List<ModifySyncStatusHandler> handlers, ModelCompareVo modelTableCompareVo) {
        this.handlers = handlers;
        this.modelTableCompareVo = modelTableCompareVo;
    }

    public boolean allMatch(ModelCompareVo modelTableCompareVo) {
        return handlers.stream().allMatch(h -> h.canModStatus(modelTableCompareVo));
    }

    public boolean anyMatch(ModelCompareVo modelTableCompareVo) {
        return handlers.stream().anyMatch(h -> h.canModStatus(modelTableCompareVo));
    }

    public boolean noneMatch(ModelCompareVo modelTableCompareVo) {
        return handlers.stream().noneMatch(h -> h.canModStatus(modelTableCompareVo));
    }
}